//package mock;
//import bean.*;
//import bean.Driver;
//
//import java.sql.*;
//import java.util.List;
//
//public class DataInserter {
//    private Connection connection;
//
//    public DataInserter(String url, String user, String password) throws SQLException {
//        this.connection = DriverManager.getConnection(url, user, password);
//    }
//
//    public void insertCities(List<City> cities) throws SQLException {
//        String sql = "INSERT INTO city (city_id, province_name, city_name, district_name, street_name) VALUES (?, ?, ?, ?, ?)";
//        try (PreparedStatement stmt = connection.prepareStatement(sql)) {
//            for (City city : cities) {
//                stmt.setString(1, city.getCity_id());
//                stmt.setString(2, city.getProvince_name());
//                stmt.setString(3, city.getCity_name());
//                stmt.setString(4, city.getDistrict_name());
//                stmt.setString(5, city.getStreet_name());
//                stmt.addBatch();
//            }
//            stmt.executeBatch();
//        }
//    }
//
//    public void insertPriceRules(List<PriceRule> rules) throws SQLException {
//        String sql = "INSERT INTO price_rule (city_id, car_type, base_price, price_per_km, price_per_min) VALUES (?, ?, ?, ?, ?)";
//        try (PreparedStatement stmt = connection.prepareStatement(sql)) {
//            for (PriceRule rule : rules) {
//                stmt.setString(1, rule.getCity_id());
//                stmt.setString(2, rule.getCar_type());
//                stmt.setString(3, rule.getBase_price());
//                stmt.setString(4, rule.getPrice_per_km());
//                stmt.setString(5, rule.getPrice_per_min());
//                stmt.addBatch();
//            }
//            stmt.executeBatch();
//        }
//    }
//
//    public void insertDrivers(List<Driver> drivers) throws SQLException {
//        String sql = "INSERT INTO driver (driver_id, driver_name, driver_phone, driver_gender, driver_age, driver_car_number, driver_car_type, driver_mark, total_orders, create_time, update_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
//        try (PreparedStatement stmt = connection.prepareStatement(sql)) {
//            for (Driver driver : drivers) {
//                stmt.setString(1, driver.getDriver_id());
//                stmt.setString(2, driver.getDriver_name());
//                stmt.setString(3, driver.getDriver_phone());
//                stmt.setString(4, driver.getDriver_gender());
//                stmt.setInt(5, driver.getDriver_age());
//                stmt.setString(6, driver.getDriver_car_number());
//                stmt.setString(7, driver.getDriver_car_type());
//                stmt.setString(8, driver.getDriver_mark());
//                stmt.setInt(9, driver.getTotal_orders());
//                stmt.setObject(10, driver.getCreateTime());
//                stmt.setObject(11, driver.getUpdateTime());
//                stmt.addBatch();
//            }
//            stmt.executeBatch();
//        }
//    }
//
//
//
//    public void insertPassengers(List<Passenger> passengers) throws SQLException {
//        String sql = "INSERT INTO passenger (passenger_id, passenger_phone, passenger_name, gender, age, create_time, update_time) VALUES (?, ?, ?, ?, ?, ?, ?)";
//        try (PreparedStatement stmt = connection.prepareStatement(sql)) {
//            for (Passenger passenger : passengers) {
//                stmt.setString(1, passenger.getPassenger_id());
//                stmt.setString(2, passenger.getPassenger_phone());
//                stmt.setString(3, passenger.getPassenger_name());
//                stmt.setString(4, passenger.getGender());
//                stmt.setInt(5, passenger.getAge());
//                stmt.setObject(6, passenger.getCreateTime());
//                stmt.setObject(7, passenger.getUpdateTime());
//                stmt.addBatch();
//            }
//            stmt.executeBatch();
//        }
//    }
//
//
//
//    public void insertCars(List<Car> cars) throws SQLException {
//        String sql = "INSERT INTO car (car_id, driver_id, car_type, car_number, car_color, car_brand, car_seat, total_orders, total_distance) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
//        try (PreparedStatement stmt = connection.prepareStatement(sql)) {
//            for (Car car : cars) {
//                stmt.setString(1, car.getCar_id());
//                stmt.setString(2, car.getDriver_id());
//                stmt.setString(3, car.getCar_type());
//                stmt.setString(4, car.getCar_number());
//                stmt.setString(5, car.getCar_color());
//                stmt.setString(6, car.getCar_brand());
//                stmt.setString(7, car.getCar_seat());
//                stmt.setString(8, car.getTotal_orders());
//                stmt.setDouble(9, car.getTotal_distance());
//                stmt.addBatch();
//            }
//            stmt.executeBatch();
//        }
//    }
//    public void insertOrderInfos(List<OrderInfo> orderInfos) throws SQLException {
//        String sql = "INSERT INTO order_info (order_id, city_id, passenger_id, driver_id, car_id, start_time, end_time, total_price, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
//        try (PreparedStatement stmt = connection.prepareStatement(sql)) {
//            for (OrderInfo info : orderInfos) {
//                stmt.setString(1, info.getOrder_id());
//                stmt.setString(2, info.getCity_id());
//                stmt.setString(3, info.getPassenger_id());
//                stmt.setString(4, info.getDriver_id());
//                stmt.setString(5, info.getCar_id());
//                stmt.setString(6, info.getStart_time());
//                stmt.setString(7, info.getEnd_time());
//                stmt.setDouble(8, info.getTotal_price());
//                stmt.setInt(9, info.getStatus());
//                stmt.addBatch();
//            }
//            stmt.executeBatch();
//        }
//    }
//    public void insertOrderDetails(List<OrderDetail> orders) throws SQLException {
//        String sql = "INSERT INTO order_detail (order_id, driver_id, pickup_time, pickup_location, destination, distance, time, base_price, mileage_price, time_price, total_price, status, payment_status, payment_type, passeger_mark, passenger_comment) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
//        try (PreparedStatement stmt = connection.prepareStatement(sql)) {
//            for (OrderDetail order : orders) {
//                stmt.setString(1, order.getOrder_id());
//                stmt.setString(2, order.getDriver_id());
//                stmt.setTimestamp(3, new Timestamp(order.getPickup_time().getTime()));
//                stmt.setString(4, order.getPickup_location());
//                stmt.setString(5, order.getDestination());
//                stmt.setDouble(6, order.getDistance());
//                stmt.setInt(7, order.getTime());
//                stmt.setDouble(8, order.getBase_price());
//                stmt.setDouble(9, order.getMileage_price());
//                stmt.setDouble(10, order.getTime_price());
//                stmt.setDouble(11, order.getTotal_price());
//                stmt.setInt(12, order.getStatus());
//                stmt.setInt(13, order.getPayment_status());
//                stmt.setInt(14, order.getPayment_type());
//                stmt.setString(15, order.getPasseger_mark());
//                stmt.setString(16, order.getPassenger_comment());
//                stmt.addBatch();
//            }
//            stmt.executeBatch();
//        }
//    }
//
//    public void close() throws SQLException {
//        if (connection != null && !connection.isClosed()) {
//            connection.close();
//        }
//    }
//}
